package com.ruoyi.planthopper.controller;

import com.ruoyi.common.core.domain.AjaxResult;

import com.ruoyi.planthopper.domain.ProvincePlot;
import com.ruoyi.planthopper.service.ProvincePlotService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @program: base-planthopper-detection-master_202130504106_李航
 * @description:
 * @author: LiHang
 * @create: 2021-09-24 19:43
 **/
@Api("地块信息处理接口")
@Slf4j
@RestController
public class ProvincePlotController {

    @Autowired
    public ProvincePlotService provincePlotService;

    /**
     * 对应省份插入地块信息
     * @param provincePlot
     */
    @ApiOperation(value = "对应省份添加插入地块信息", notes = "示例:http://192.168.1.217:8180/insertPlot\n请求头附带省份地块信息")
    @PostMapping("/insertPlot")
    @ApiImplicitParams({
            //@ApiImplicitParam(name = "id",value="对应的数据id",paramType = "query",dataType = "int"),
            @ApiImplicitParam(name = "province",value="省份",paramType = "query",dataType = "String"),
            @ApiImplicitParam(name = "city",value="市",paramType = "query",dataType = "String"),
            @ApiImplicitParam(name = "district",value="区",paramType = "query",dataType = "String"),
            //@ApiImplicitParam(name = "plot",value="地块",paramType = "query",dataType = "String")

    })
    public AjaxResult insertPlot(ProvincePlot provincePlot){
        provincePlotService.insertProvincePlot(provincePlot);
        return AjaxResult.success("插入成功");
    }

    /**
     * 根据地区查询地块信息
     * @param provincePlot
     * @return
     */
    @ApiOperation(value = "根据地区查询地块信息", notes = "示例:http://192.168.1.217:8180/selectPlotbyProvince\n请求头附带省份区域信息")
    //@ResponseBody
    @PostMapping("/selectPlotbyProvince")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id",value="对应的数据id",paramType = "query",dataType = "int"),
            @ApiImplicitParam(name = "province",value="省份",paramType = "query",dataType = "String"),
            @ApiImplicitParam(name = "city",value="市",paramType = "query",dataType = "String"),
            @ApiImplicitParam(name = "district",value="区",paramType = "query",dataType = "String"),
            @ApiImplicitParam(name = "plot",value="地块",paramType = "query",dataType = "String")

    })
    public AjaxResult selectPlotbyProvince(ProvincePlot provincePlot){
        List<String> selectPlotbyProvince= provincePlotService.selectPlotbyProvince(provincePlot);

        return AjaxResult.success(selectPlotbyProvince);
    }
}
